/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package analyzer;
import java.io.IOException;
import java.util.Arrays;
import java.util.Random;
//import java.math.*;

/**
 *
 * @author Matrix
 */
public class ACl {
    public static java.io.BufferedReader stdIn = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
    public static final int arrLength = 5;

    public static void doTableTask() {
        for (int i = 0; i < 100; i++) {
            System.out.print(i+1+" ");
            ACl.prnArray(ACl.doError(" I 'll always use OOP", 1));
        }
    }

    public static char[] doError(String str, int errC) {
        char[] strTemp = str.toCharArray();
        for (int i = 0; i < errC; i++) {
            strTemp[new Random().nextInt(str.toCharArray().length)] = (char)(new Random().nextInt(57)+65);
        }
        return strTemp;
    }

    public static void prnIntCharsTable() {
        for (int i = 65; i < 123; i++) System.out.println(i+ " " +(char)i);
    }

    public static int nod(int x, int y) {
        //int k = y;
        if (x % y != 0) {
            int k = nod(y, x % y);
            return k;
        }
        else return y;
        //return k;
    }

    public static double twoToPow(double x) {
        return Math.pow(2, x);
    }

    public static double[] genRandArr(int n) {
        double[] c = new double[n];
        for (int i = 0; i < n; i++) {
            c[i] = new Random().nextDouble();
        }
        ACl.prnArray(c);
        return c;
    }

    public static double[] arrMulti(double[] m, double[] n) {
        double[] c = new double[m.length];
        for (int i = 0; i < m.length; i++) {
            c[i] = m[i]*n[i];
        }
        return c;
    }

    public static String strReverse(String inpStr) {
        inpStr = new StringBuffer(inpStr).reverse().toString();
        System.out.println("reversed String: " + inpStr);
        return inpStr;
    }

    public static int[] genCardArr() {
        int[] arr = new int[52];
        for (int i = 0; i < 52; i++) {
            arr[i] = i+1;
        }
        return arr;
    }

    public static int[] shuffle(int[] arr) {
        //ACl.prnArray(arr);
        //System.out.println(arr);
        for (int i = 0; i < arr.length; i++) {
            int tempIx = new Random().nextInt(arr.length);
            int tempDgt = arr[tempIx];
            arr[tempIx] = arr[i];
            arr[i] = tempDgt;
        }
        return arr;
    }

    public static void shift(int[] arr) {
        int[] temp = arr.clone();
        int i = 0, j, k = 1;
        do {
            ACl.prnArray(arr);
            System.out.println("..." + k);
            j = arr[i];
            arr[i] = arr[i+1];
            arr[i+1] = j;
            if (i == (arr.length-2)) i = 0; else i +=1;
            k += 1;
        } while (!(Arrays.equals(arr, temp)));
        System.out.println("Done");
    }

    public static long summSmall(long foo) {
        long bar = 0;
        for (long i = 1; i < foo; i++) {
            System.out.print(i + " ");
            bar += i;
            i += 1; // nechet
        }
        System.out.println(" ");
        return bar;

    }

    public static boolean is2e(int foo) {
        System.out.println("into digit " + foo);
        boolean temp;
        char[] arr = Integer.toBinaryString(foo).toCharArray();
        if ((arr[0] == '1')/*&&(arr.length > 1)*/) temp = true;
        else return false;
        for (int i = 1; i < arr.length; i++) {
            if (arr[i] == '1') {return false;}
        }
        return temp;
    }

    public static int[] Nechet(int[] arr) {
        int temp[] = new int[arr.length];
        int k = 0;
        for (int i = 0; i< arr.length; i++) {
            if ((arr[i] % 2) == 1) {
                temp[k] = arr[i];
                k += 1;
            }
            if (k == 0) temp[k] = -1;
        }
        return temp;
    }

    public static void prnArray(int[] arr) {
        for (int i =0; i < arr.length; i++)
            System.out.print(arr[i] + " ");
    }

    public static void prnArray(double[] arr) {
        for (int i =0; i < arr.length; i++)
            System.out.print(arr[i] + " ");
        System.out.println(" ");
    }

    public static void prnArray(char[] arr) {
        for (int i =0; i < arr.length; i++)
            System.out.print(arr[i] + " ");
         System.out.println("");
    }
    
    public static void prnArray(Symbol[] arr) {
        
    }




}

